using System;
using System.Collections.Generic;
using System.Text;
using LispLib;

namespace Noein.GeneticAlgorithm.New
{
    public abstract class Mutation
    {
        protected Selector selector;

        public Mutation(Selector selector)
        {
            this.selector = selector;
        }

        public abstract List<Individual> Reproduce(List<Individual> pop, int count);
    }

    public class Dummy : Mutation
    {
        public Dummy(Selector s)
            : base(s)
        {
        }

        public override List<Individual> Reproduce(List<Individual> pop, int count)
        {
            List<Individual> offspring = new List<Individual>();

            List<Individual> parents = selector.Select(pop, count);
            for (int i = 0; i < count; i++)
            {
                List<Interpreter.Pair> geno = new List<Interpreter.Pair>();
                foreach (Interpreter.Pair tree in parents[i].Genotype)
                {
                    geno.Add(Interpreter.Pair.Clone(tree));
                }

                offspring.Add(new Individual(geno));
            }
            return offspring;
        }
    }
}
